package io;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/*
  缓冲输出流的缓冲区问题
 */
public class BOSDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("bos.txt");//文件流
        BufferedOutputStream bos = new BufferedOutputStream(fos);//缓冲流
        String line = "天青色等烟雨，而我在等你";
        byte[] data = line.getBytes(StandardCharsets.UTF_8);
        bos.write(data);
        bos.flush();//flush冲水，每次都把缓冲区中的数据写出
        System.out.println("写出完毕！");
        bos.close();

    }
}
